In an object-oriented programming paradigm, an object represents some real-world entity as a data structure that has properties including an identity, state, and behavior. The identity is the property of an object that distinguishes an object from other objects. State is data that is stored in an object, and behavior is a set of actions that can be performed by an object. Furthermore, relationships between objects can be established by way of inheritance. In other words, an object can inherit state and behavior from another object. There are two distinct styles of object-oriented programming, namely class-based or prototype-based.
Class-based object-oriented languages include classes and instances. A class defines properties that characterize a particular set of objects. Stated differently, a class provides a set of instructions (a.k.a. constructors) to build a particular type of object. An instance is an instantiation of a class, or, in other words, an object constructed from a specific class. Further, inheritance is specified by way of a class. For example, a class can be specified as a subclass of an already existing class. In this case, the subclass inherits all the properties of the superclass and can optionally add new properties or override inherited properties.
In prototype-based object-oriented languages, there are no explicit classes but rather only objects. While an object can be created from nothing, it is more prevalent for objects to be created by cloning existing objects referred to as prototype objects or simply prototypes. Here, the prototype acts as a template to construct a new object with the same object properties. More specifically, objects can be constructed from a function defining a prototype by calling the function in a constructor context, for example utilizing the “new” keyword.” Objects can inherit from other objects utilizing a prototype property of an object to reference another object. In the context of cloning, for instance, the prototype property of the newly created object can be set to reference the prototype object.